/**
 * 
 */
package cre.gutwo.util;

import java.util.List;

import org.apache.poi.ss.usermodel.Cell;

import cre.gutwo.domain.DataModel;

/**
 * @author Cre.Gu
 *
 */
public class PoiUtils {
	protected static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(PoiUtils.class);

	public static String getStringCellValue(Cell cell) {
		try {
			switch (cell.getCellType()) {
			case Cell.CELL_TYPE_STRING:
				return cell.getStringCellValue();
			case Cell.CELL_TYPE_NUMERIC:
				return String.valueOf(Double.valueOf(cell.getNumericCellValue()).intValue());
			default:
				return cell.getStringCellValue();
			}

		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
	}

	public static void print(List<DataModel> destDatas) {
		log.info("===============================");
		log.info("转换之后的数据");
		for (DataModel dataModel : destDatas) {
			if (dataModel != null)
				log.info(dataModel.toString());
		}
		log.info("===============================");
	}
}
